﻿/*****************************************************************************
 * Hyldahl.Services.TaskProcessing.DisplayMessage Created by: MSH 2008.07.22
 * --------------------------------------------------------------------------
 * FileName: DisplayMessageTaskProcessor.cs
 * --------------------------------------------------------------------------
 * Copyright 2008 Martin Sixhøj Hyldahl
 *****************************************************************************/

using System;
using System.Collections.Generic;
using System.Text;

namespace Hyldahl.Services.TaskProcessing.DisplayMessage
{
    public class DisplayMessageTaskProcessor : TaskProcessor
    {
        /*****************************************************
         * METHODS
         *****************************************************/

        #region TaskProcessor Members

        /// <summary>
        /// Processes the specified task.
        /// </summary>
        /// <param name="task">The task.</param>
        public override void Process(Task task)
        {
            if (task == null)
                throw new ArgumentNullException("task");

            if (string.Compare(task.TaskType, this.TaskType, true) != 0)
                throw new ArgumentException("Invalid task type.");

            if (string.IsNullOrEmpty(task.Data))
                throw new ArgumentException("No task data.", "task");

            Console.WriteLine("----------------------------------");
            Console.WriteLine(task.Data);
            Console.WriteLine("----------------------------------");

            task.ResultData = "Message Displayed";

            task.IsProcessed            = true;
            task.CompletedSuccessfully  = true;
        }

        /*****************************************************
         * PROPERTIES
         *****************************************************/

        /// <summary>
        /// Gets the type of the supported task.
        /// </summary>
        /// <value>The type of the supported task.</value>
        public override string TaskType
        {
            get { return "DisplayMessage"; }
        }

        #endregion
    }
}